package com.huobao.yunying.activitys_log_reg;

import java.util.Map;

import org.xutils.view.annotation.ViewInject;

import com.huobao.yunying.base.HuobaoBaseActivity;
import com.huobao.yunying.https.Http;
import com.huobao.yunying.https.HttpListener;
import com.huobao.yunying.https.HttpUtil;
import com.huobao.zhangying.R;

import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class Act_SetNewPwd extends HuobaoBaseActivity {

	@ViewInject(R.id.edt_pwd)
	private EditText edt_pwd;
	@ViewInject(R.id.edt_re_pwd)
	private EditText edt_re_pwd;
	private String id, activation;

	@Override
	protected int getContentView() {
		// TODO Auto-generated method stub
		return R.layout.layout_setnewpwd;
	}

	@Override
	protected String getTitleText() {
		return "重设密码";
	}

	@Override
	protected void init() {
		id = getIntent().getStringExtra("id");
		activation = getIntent().getStringExtra("activation");
	}

	public void onFindClick(View view) {
		String pwd = edt_pwd.getText().toString().trim();
		String re_pwd = edt_re_pwd.getText().toString().trim();
		if (pwd.equals(re_pwd) == false) {
			Toast.makeText(context, "两次输入不一致", Toast.LENGTH_SHORT).show();
			return;
		}
		if (pwd.length() < 6 || pwd.length() > 20) {
			Toast.makeText(context, "密码长度6-20", Toast.LENGTH_SHORT).show();
			return;
		}
		Map<String, String> map = HttpUtil.getParams("app", "findpwd", "act", "password_edit", "id", id, "activation",
				activation, "new_password", pwd, "confirm_password", re_pwd);
		Http.getInstant().sendRequest(context, map, new HttpListener() {

			@Override
			public void onHttpSuccess(String result) {
				Toast.makeText(context, "密码修改成功，请用新密码登录", Toast.LENGTH_SHORT).show();
				setResult(RESULT_OK);
				finish();
			}

			@Override
			public void onHttpError(String error) {
				// TODO Auto-generated method stub

			}
		});
	}

}
